package game.entity;

import game.util.Direction;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;

/**
 * @author zsq
 * @date 2023/1/15 下午8:24
 */
public abstract class AbstractEntity {

    protected int x;

    protected int y;

    protected char c;

    protected Image image;

    protected boolean broken;

    protected Direction direction;

    private int bornX;

    private int bornY;

    private boolean dead;

    public AbstractEntity(int x, int y, char c) {
        this.x = x;
        this.y = y;
        bornX = x;
        bornY = y;
        this.c = c;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public char getC() {
        return c;
    }

    public void setC(char c) {
        this.c = c;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public void draw(GraphicsContext g, int frame) {
       if (!isDead()) {
           g.drawImage(image, x, y);
       }
    }

    public void changeDirection(Direction direction) {
        this.direction = direction;
    }

    public Direction getDirection() {
        return direction;
    }

    public void resetPosition() {
        x = bornX;
        y = bornY;
    }

    public void setDead() {
        this.dead = true;
    }

    public boolean isDead() {
        return dead;
    }
}
